package com.ruoyi.web.controller.dailySettlementTimeLog;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.ruoyi.system.util.StoreIdUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.DailySettlementTimeLog;
import com.ruoyi.system.service.IDailySettlementTimeLogService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 日结时间操作日志 Controller
 *
 * @author ruoyi
 * @date 2025-05-07
 */
@Api(tags="日结时间操作日志")
@RestController
@RequestMapping("/system/dailySettlementTimeLog")
public class DailySettlementTimeLogController extends BaseController
{
    @Autowired
    private IDailySettlementTimeLogService dailySettlementTimeLogService;

    @Autowired
    private StoreIdUtils storeIdUtils;


    /**
     * 查询日结时间操作日志列表
     */
    @ApiOperation("查询日结时间操作日志列表")
    @PreAuthorize("@ss.hasPermi('system:log:list')")
    @GetMapping("/list")
    public TableDataInfo list(DailySettlementTimeLog dailySettlementTimeLog)
    {
        startPage();
//        dailySettlementTimeLog.setStoreId(storeIdUtils.getStoreId());
        List<DailySettlementTimeLog> list = dailySettlementTimeLogService.selectDailySettlementTimeLogList(dailySettlementTimeLog);
        return getDataTable(list);
    }

    /**
     * 导出日结时间操作日志列表
     */
    @ApiOperation("导出日结时间操作日志列表")
    @PreAuthorize("@ss.hasPermi('system:log:export')")
    @Log(title = "日结时间操作日志", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DailySettlementTimeLog dailySettlementTimeLog)
    {
//        dailySettlementTimeLog.setStoreId(storeIdUtils.getStoreId());
        List<DailySettlementTimeLog> list = dailySettlementTimeLogService.selectDailySettlementTimeLogList(dailySettlementTimeLog);
        ExcelUtil<DailySettlementTimeLog> util = new ExcelUtil<DailySettlementTimeLog>(DailySettlementTimeLog.class);
        util.exportExcel(response, list, "日结时间操作日志数据");
    }

    /**
     * 通过id获取日结时间操作日志详细信息
     */
    @ApiOperation("通过id获取日结时间操作日志详细信息")
    @PreAuthorize("@ss.hasPermi('system:log:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(dailySettlementTimeLogService.selectDailySettlementTimeLogById(id));
    }

    /**
     * 新增日结时间操作日志
     */
    @ApiOperation("新增日结时间操作日志")
    @PreAuthorize("@ss.hasPermi('system:log:add')")
    @Log(title = "日结时间操作日志", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DailySettlementTimeLog dailySettlementTimeLog)
    {
//        dailySettlementTimeLog.setStoreId(storeIdUtils.getStoreId());
        return toAjax(dailySettlementTimeLogService.insertDailySettlementTimeLog(dailySettlementTimeLog));
    }

    /**
     * 修改日结时间操作日志
     */
    @ApiOperation("修改日结时间操作日志")
    @PreAuthorize("@ss.hasPermi('system:log:edit')")
    @Log(title = "日结时间操作日志", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DailySettlementTimeLog dailySettlementTimeLog)
    {
//        dailySettlementTimeLog.setStoreId(storeIdUtils.getStoreId());
        return toAjax(dailySettlementTimeLogService.updateDailySettlementTimeLog(dailySettlementTimeLog));
    }

    /**
     * 通过id批量删除日结时间操作日志信息
     */
    @ApiOperation("通过id批量删除日结时间操作日志信息")
    @PreAuthorize("@ss.hasPermi('system:log:remove')")
    @Log(title = "日结时间操作日志", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(dailySettlementTimeLogService.deleteDailySettlementTimeLogByIds(ids));
    }
}

